

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>有赞商品管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <#include "../../include/layui.ftl" />
    <#include "../../include/pTable.ftl" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <form  id="queryForm">
                <input type="hidden" id="className" name="className" value="${className!}" />
                <input type="hidden" id="modleName" name="modleName" value="${modleName!}" />
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">类型</label>
                        <div class="layui-input-block">
                            <select name="type">
                                <option value="0" selected="">出售中</option>
                                <option value="1">仓库中</option>
                            </select>
                        </div>
                    </div>
                </div>
            </form>
        </div>

        <div class="layui-card-body">

            <table id="lay-table" lay-filter="lay-table"></table>
            <script type="text/html" id="toolbar">
            </script>
        </div>
    </div>
</div>
<script>
    var $ = null,layer = null,$tables = null,table = null;
    layui.config({
        base: '${path}/plug-in/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index','tables','layers','view'],function () {
        var tables = layui.tables,
            view = layui.view,
            layers = layui.layers;
        $ = layui.$,layer = layui.layer,table = layui.table;
        var parmer = {
            url:'/console/youzanShop/rewrite/list',
            request: {
                pageName: 'page_no' //页码的参数名称，默认：page
                , limitName: 'page_size' //每页数据量的参数名，默认：limit
            },
            cols:[[
                    {field:"item_id",width:'8%',title:"商品Id"}
                    ,{field:"title",width:'10%',title:"商品名称"}
                    ,{field:"item_type",width:'8%',title:"商品类型",templet: function(d){
                        if(d.item_type == 0){
                            return '普通商品 ';
                        }else if(d.item_type == 3){
                            return 'UMP降价拍';
                        }else if(d.item_type == 5){
                            return '外卖商品';
                        }else if(d.item_type == 10){
                            return '分销商品';
                        }else if(d.item_type == 20){
                            return '会员卡商品';
                        }else if(d.item_type == 21){
                            return '礼品卡商品';
                        }else if(d.item_type == 22){
                            return '团购券';
                        }else if(d.item_type == 25){
                            return '批发商品';
                        }else if(d.item_type == 30){
                            return '收银台商品';
                        }else if(d.item_type == 31){
                            return '知识付费商品';
                        }else if(d.item_type == 35){
                            return '酒店商品';
                        }else if(d.item_type == 40){
                            return '美业商品';
                        }else if(d.item_type == 60){
                            return '虚拟商品';
                        }else if(d.item_type == 61){
                            return '电子卡券';
                        }else{
                            return '未知类型';
                        }
                    }}
                    ,{field:"image",width:'10%',title:"商品图片",templet: function(d){
                        return '<a href="javascript:void(0);" onclick="viewImg(\''+d.image+'\')">点击查看</a>';
                    }}
                    ,{field:"price",width:'8%',title:"商品价格(分)"}
                    ,{field:"origin",width:'8%',title:"划线价格(元)"}
                    ,{field:"post_fee",width:'6%',title:"运费(分)"}
                    ,{field:"update_time",width:'10%',title:"最后更新时间"}
                    ,{field:"detail_url",width:'15%',title:"商品详情",templet: function(d){
                        return '<a href="'+d.detail_url+'" target="_blank">'+d.detail_url+'</a>';
                    }}
                ]]
        };
        $tables = tables.renderTable(parmer);

        //头工具栏事件
        table.on('toolbar(lay-table)', function(obj){
            switch(obj.event){
                case '05':
                    var where = $("#queryForm").serializeObject();
                    $tables.reload({
                        where: where,
                        text: {none: '暂无数据！'}
                    });
                    break;
            };
        });
    });
    function viewImg(url) {
        console.log(url);
        var data = {
            "title": "查看图片", //相册标题
            "id": 123, //相册id
            "start": 0, //初始显示的图片序号，默认0
            "data": [   //相册包含的图片，数组格式
                {
                    "alt": "图片",
                    "pid": 666, //图片id
                    "src": url, //原图地址
                    "thumb": url //缩略图地址
                }
            ]
        }
        layer.photos({
            photos: data //格式见API文档手册页
        });
    }
</script>
</body>
</html>